package com.meihua.pickerviewlibrary;

import android.content.Context;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Author: liming
 * Time: 2017/10/19
 */

@Deprecated
public class RelativesPickerView extends OptionsPickerView<String> {

    // 年龄类型集合
    private ArrayList<Map<String, String>> mRelative = new ArrayList<>();
    private OnRelativeMoreListener mOnRelativeMoreListener;
    public RelativesPickerView(Context context, List<String> ageList) {
        super(context);
        initRelatives(ageList);
    }

    private void initRelatives(List<String> ageList) {
        for (String age : ageList) {
            int indexOf = ageList.indexOf(age);
            Map<String, String> map=new HashMap<>();
            map.put("area_name", age);
            map.put("area_id", (indexOf+1) +"");
            mRelative.add(map);
        }
        setTitle("选择年龄");
        setPicker(mRelative);
        setCyclic(false);
        setSelectOptions(0);
        setOnOptionsSelectListener(new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int option1, int option2, int option3) {
                if (mOnRelativeMoreListener != null){
                    mRelative.get(option1);
                    mOnRelativeMoreListener.onRelaviteSelectMore(mRelative.get(option1).get("area_name"), option1+1);
                }
            }
        });

    }

    public void setmOnRelativeMoreListener(OnRelativeMoreListener mOnRelativeMoreListener) {
        this.mOnRelativeMoreListener = mOnRelativeMoreListener;
    }

    public interface OnRelativeMoreListener {
        void onRelaviteSelectMore(String Relatives, int position);
    }
}
